package com.bing.bingPro.controller.fiveOrder;

import com.bing.bingPro.ExcelUtil;
import com.bing.bingPro.common.BaseResult;
import com.bing.bingPro.controller.dto.TFiveOrderTypeDto;
import com.bing.bingPro.controller.vo.TCpOrderVo;
import com.bing.bingPro.service.TCpOrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 工单详表-投诉工单详表(t_cp_order)
 */
@RestController
public class TCpOrderController {

    @Resource
    private TCpOrderService tCpOrderService;

    /**
     * 投诉工单详表-列表
     *
     * @param tOrderYearDto
     * @return
     */
    @PostMapping("/cpList")
    public BaseResult<List<TCpOrderVo>> cpList(@RequestBody TFiveOrderTypeDto tOrderYearDto) {
        return new BaseResult<>(this.tCpOrderService.cpList(tOrderYearDto));
    }


    /**
     * 投诉工单详表-导出
     *
     * @param response
     * @param tOrderYearDto
     * @throws Exception
     */
    @PostMapping("/exportCp")
    public void exportCp(HttpServletResponse response, @RequestBody TFiveOrderTypeDto tOrderYearDto) throws Exception {
        List<TCpOrderVo> tCpOrderVos = tCpOrderService.exportCp(tOrderYearDto);
        String monthOrDayTime = "投诉工单详表" + tOrderYearDto.getTime();
        ExcelUtil.writeExcel(response, tCpOrderVos, monthOrDayTime, "投诉工单详表" + tOrderYearDto.getTime(), TCpOrderVo.class);

    }

    public static void main(String[] args) {

    }
}
